package com.airycode.distribution.distribution1.utils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zkr-fanxirui on 2017/8/14.
 */
public class PageUtils {
    public static List<String> getItems(int gotoPageNo, int totalPage) {
        List<String> items = new ArrayList<String>();
        if (totalPage <= 0) {
            items.add(0+"");
        }
        int start = 1;
        if(gotoPageNo>=7&&totalPage>10){
            start = gotoPageNo-5;
        }
        int end = start+9>totalPage?totalPage:start+9;
        int n=0;
        for(int i=start;i<=end;i++){
            if(gotoPageNo>6&&n==0&&totalPage>10){
                items.add(1+"");
                n++;
            }else if(gotoPageNo>6&&n==1&&totalPage>10){
                items.add("...");
                n++;
            }else{
                items.add(i+"");
            }
        }
        return items;
    }
}
